//
//  HelpFrame.m
//  bitcoin
//
//  Created by caiyajun on 2018/5/9.
//  Copyright © 2018年 比特币. All rights reserved.
//

#import "HelpFrame.h"

@implementation HelpFrame
- (void)setHelpModel:(HelpModel *)helpModel
{
    _helpModel = helpModel;
    [self setupFrame];
}


- (void)setShowAllFlag:(BOOL)showAllFlag{
    _showAllFlag = showAllFlag;
    [self setupFrame];
}
- (void) setupFrame{
    //编号
    CGSize answerSize = [_helpModel.title sizeWithFont:[UIFont boldSystemFontOfSize:16] maxSize:CGSizeMake(CGFLOAT_MAX, 16)];
    _answerLabelFrame = CGRectMake(21, 15, answerSize.width, answerSize.height);
    
    //显示按钮
    _showBtnFrame = CGRectMake(0, 0, ScreenWidth, 44);
    
    
    if (self.showAllFlag){
        //内容
        NSString * htmlString = [NSString stringWithFormat:@"%@",_helpModel.content];
        NSMutableAttributedString * attrStr = [[NSMutableAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
        [attrStr addAttribute:NSForegroundColorAttributeName value:RGBColor(153, 153, 153) range:NSMakeRange(0, attrStr.length)];
        [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, attrStr.length)];
        
        CGSize contentLabeSize =  [attrStr boundingRectWithSize:CGSizeMake(ScreenWidth-41, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading context:nil].size;
        _contentLabelFrame = CGRectMake(21, 47, contentLabeSize.width, contentLabeSize.height);
        
        _lineViewFrame=CGRectMake(0, CGRectGetMaxY(_contentLabelFrame) + 27, ScreenWidth, 2);
        _cellHeight =  CGRectGetMaxY(_contentLabelFrame) + 29;
    }else{
        _contentLabelFrame=CGRectZero;
        _lineViewFrame=CGRectMake(0, 44, ScreenWidth, 2);
        _cellHeight = 46;
    }
    
    
    
}
@end
